import 'package:flutter/material.dart';
import 'package:hao_ke/widgets/project_widget.dart';
import 'package:hao_ke/widgets/store_widget.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

class AddProject extends StatefulWidget {
  const AddProject({super.key});

  @override
  State createState() {
    return _AddProjectState();
  }
}



class _AddProjectState extends State<AddProject> {

  String bookTime = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('新增项目订单'),
        centerTitle: true,
      ),
      body:  Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image: new AssetImage('images/back_image.jpg'),
                fit: BoxFit.cover
            )
        ),
        child: Container(
          margin: EdgeInsets.all(10),
          padding: EdgeInsets.all(20),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10),
            color: Color.fromRGBO(200, 200, 200, 0.5),
          ),
          child: Form(
            child: Column(
              children: [
                const StoreWidget(),
                ProjectWidget(),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('$bookTime'),
                    TextButton(onPressed: () {
                      TDPicker.showDatePicker(context, title: '选择时间',
                          onConfirm: (selected) {
                            setState(() {
                              bookTime = '${selected['year'].toString().padLeft(4, '0')}-'
                                  '${selected['month'].toString().padLeft(2, '0')}-'
                                  '${selected['day'].toString().padLeft(2, '0')} '
                                  '${selected['hour'].toString().padLeft(2, '0')}:'
                                  '${selected['minute'].toString().padLeft(2, '0')}';
                            });
                          },
                          pickerHeight: 300,
                          useHour: true,
                          useMinute: true,
                          dateStart: [2008, 01, 01],
                          dateEnd: [2066,12,31],
                      );
                  },
                      child: Text("选择预约时间"))],
                ),
                TextFormField(
                  decoration: InputDecoration(
                      labelText: "顾客"
                  ),
                ),
                SizedBox(height: 10,),
                ElevatedButton(
                  style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.all(Colors.blue),
                  ),
                  onPressed: () {
                  },
                  child: Text('提交',style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold,fontSize: 16),),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}





